﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master"
    Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="ZYStudios.Helper" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    留言板
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../../Content/GuestBook.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function HideNext(a) {
            var answer = $(a).next();
            if (answer.is(':visible')) {
                answer.slideUp();
            } else {
                answer.slideDown();
            }
        }

        function FormVerification() {
            if (jQuery.trim($("#pUserName").val()) == '') {
                alert('用户姓名不能为空');
                return false;
            }

            if (jQuery.trim($("#pContent").val()) == '') {
                alert('留言内容不能为空');
                return false;
            } 
            return true;
        }

      
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% if (ViewData["ErrorMsg"] != null)
       { %>
    <script type="text/javascript">
        <% ="alert('"+ViewData["ErrorMsg"].ToString()+"');" %>
    </script>
    <%} %>
    <div class="PageContent">
        <a class="MenuTitle">访客留言</a><br />
        <br />
        <div>
            <% var aMessages = ViewData["Messages"] as List<ZYStudios.Models.UserMessageEditModel>; %>
            <span class="messagelist">
                <li style="padding-top: 4px;padding-bottom: 4px;">
                    <div class="CommentFormHeader" id="fabiao" onclick="HideNext(this);" style="cursor: pointer">
                        点击发表留言</div>
                    <div class="CommentFormTable" style="display: none">
                        <% using (Html.BeginForm("PostMessage", "GuestBook", FormMethod.Post, new { style = "height:300px" }))
                           {%>

                        <table>
                        <tr>
                        <td><label>
                            用户姓名：</label></td>
                        <td><%=Html.TextBox("pUserName", null, new { @class = "inputbox" })%></td>
                        </tr>
                        <tr>
                        <td><label>
                            用户QQ ：</label></td>
                        <td><%=Html.TextBox("pUserQQ", null, new { @class = "inputbox" })%></td>
                        </tr>
                        <tr>
                        <td><label>
                            用户邮箱：</label></td>
                        <td><%=Html.TextBox("pUserEmail", null, new { @class = "inputbox" })%></td>
                        </tr>
                        <tr>
                        <td><label>
                            用户手机：</label></td>
                        <td><%=Html.TextBox("pUserPhone", null, new { @class = "inputbox" })%></td>
                        </tr>
                        <tr>
                        <td><label style="vertical-align: top;">
                            留言内容：</label></td>
                        <td><%=Html.TextArea("pContent", new { @class = "inputbox", style = "width:400px;height:100px;margin-top: 2px;" })%></td>
                        
                        </tr>
                        <tr>
                        <td><label>
                            验证码：</label></td>
                        <td align="left"><%=Html.TextBox("pCheckCode", null, new { @class = "inputbox", style = "width:40px;" })%><img src="/CheckCode/" /></td>
                        </tr>
                        <tr>
                        <td></td>
                        <td align="left"><input type="submit" class="submit id="button" value="发表" style="margin:0px" onclick="return FormVerification();" /></td>
                        </tr>
                        </table>
                        <br />
                        <%} %>
                    </div>
                </li>
                <%
                    foreach (var aItem in aMessages)
                    { %>
                <li><span>留言用户 : </span><span>
                    <%=Html.Encode(aItem.UserName)%></span> <span>
                        <%="   留言时间 ： " + aItem.MessageDate.ToString()%></span>
                    <br />
                    <br />
                    <span>
                        <%=Html.Encode(aItem.Content)%></span>
                        
                <%if (aItem.HasReply)
                  { %>
                  <br />
                  <br />
                  <span style="color:Red">管理员回复:</span>
                  <span><%=aItem.Reply%></span>
                <% }%>
                     
                </li>

                
                <%}
                        int Current = (int)ViewData["Current"];
                        int Count = (int)ViewData["Count"];
                        int PageSize = (int)ViewData["PageSize"];%>

                        <%=Html.Pager(1, Current, Count, PageSize) %>
            </span>
        </div>
    </div>
</asp:Content>
